<template>
	<view class="sti_verify_page" :style="'padding-bottom:'+ pageSafeArea +'rpx;'">
		<view class="groupmanage_input_box box_bg">
			<view class="mr-5 label" style="width: 110rpx;">用户昵称</view>
			<view class="ml-10">{{info.name}}</view>
		</view>
		<view class="groupmanage_input_box box_bg">
			<view class="mr-5 label" style="width: 110rpx;">用户电话</view>
			<view class="ml-10">{{info.mobile}}</view>
		</view>
		<view class="groupmanage_arr_box box_bg">
			<view style="width: 100%;padding: 30rpx 0;">
				<view class="mr-5 f-14">销售合同</view>
				<view class="mt-5">
					<uni-row :gutter="20">
						<uni-col v-for="(item,index) in info.contract" :key="index" :span="6">
							<view class="upload_img_box">
								<image class="upload_img" :src="picUrl+item" mode="aspectFill"
									@click="checkImg(1,index)"></image>
							</view>
						</uni-col>
					</uni-row>
				</view>
			</view>
		</view>
		<view class="groupmanage_arr_box box_bg">
			<view style="width: 100%;padding: 30rpx 0;">
				<view class="mr-5 f-14">定金收据</view>
				<view class="mt-5">
					<uni-row :gutter="20">
						<uni-col v-for="(item,index) in info.invoice" :key="index" :span="12">
							<view class="upload_img_box">
								<image class="upload_img" :src="picUrl+item" mode="aspectFill"
									@click="checkImg(2,index)"></image>
							</view>
						</uni-col>
					</uni-row>
				</view>
			</view>
		</view>
		<view class="groupmanage_arr_box box_bg">
			<view style="width: 100%;padding: 30rpx 0;">
				<view class="mr-5 f-14">身份证信息</view>
				<view class="mt-5">
					<uni-row :gutter="20">
						<uni-col v-for="(item,index) in info.card_photo" :key="index" :span="12">
							<view class="upload_img_box">
								<image class="upload_img" :src="picUrl+item" mode="aspectFill"
									@click="checkImg(3,index)"></image>
							</view>
						</uni-col>
					</uni-row>
				</view>
			</view>
		</view>
		<view class="bottom_block_fixed" :style="'padding-bottom:'+ bottomSafeArea+'rpx;'">
			<view v-if="info.sign_status==0" class="next_step_btn" @click="submitStiVerify">发放权益</view>
			<view v-else class="next_step_btn_def">已发放</view>
		</view>
	</view>
</template>

<script>
	import {
		getStiVerifyInfo,
		submitStiVerify
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				user_id: '',
				info: '',
				picUrl: app.globalData.picUrl,
				onlinePic: app.globalData.onlinePic,
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom + 80,
				pageSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets
					.bottom + 350 : 350,
				bottomSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets
					.bottom : 15
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
			if (uni.getStorageSync('onload')) {
				uni.showLoading({})
				this.getStiVerifyInfo()
			}
		},
		onLoad(options) {
			uni.showLoading({})
			this.user_id = options.scene
			this.getStiVerifyInfo()
			var params = {
				event_code: 'sti宠粉活动',
				path: 'pages/sti/verify',
				event_id: '',
				title: '',
				source_page: 'sti宠粉活动-核销',
				value: '',
			}
			app.BurialPoint(params)
		},
		methods: {
			getStiVerifyInfo() {
				getStiVerifyInfo({
					user_id: this.user_id,
					huodong_version:2
				}).then(res => {
					if (res.state == 1) {
						this.info = res.data.info
						uni.hideLoading()
						//is_enroll:,   是否提交  0 未提交  1 已提交
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			checkImg(type, index) {
				var that = this
				if (type == 1) {
					var urls = that.info.contract
				} else if (type == 2) {
					var urls = that.info.invoice
				} else if (type == 3) {
					var urls = that.info.card_photo
				}
				var urllist = []
				urls.forEach(function(item, index) {
					item = that.picUrl + item
					urllist.push(item)
				});
				uni.previewImage({
					urls: urllist,
					current: index
				})
			},
			submitStiVerify() {
				submitStiVerify({
					user_id: this.user_id,
					huodong_version:2
				}).then(res => {
					if (res.state == 1) {
						this.getStiVerifyInfo()
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			}
		},
	}
</script>

<style lang="scss">
	.sti_verify_page {
		padding: 70rpx;

		.groupmanage_input_box {
			height: 80rpx;
			font-size: 26rpx;
			margin-top: 20rpx;
			padding: 0 30rpx;
			display: flex;
			align-items: center;
			border-radius: 4px;
			background-color: #F7F7F7;
			border: 2rpx solid #F7F7F7;

			.label {
				font-size: 26rpx;
			}
		}

		.groupmanage_arr_box {
			font-size: 26rpx;
			margin-top: 20rpx;
			padding: 0 30rpx;
			border-radius: 4px;
			background-color: #F7F7F7;
			border: 2rpx solid #F7F7F7;
		}

		.upload_img_box {
			width: 100%;
			height: 168rpx;
			margin-top: 20rpx;
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
			border-radius: 8rpx;
			background-color: #F2F2F2;
		}

		.upload_img {
			width: 100%;
			height: 168rpx;
			border-radius: 8rpx;
			vertical-align: middle;
		}

		.bottom_block_fixed {
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 1;
			padding-left: 30rpx;
			padding-right: 30rpx;
			background-color: #ffffff;
		}

		.next_step_btn {
			display: flex;
			align-items: center;
			justify-content: center;
			color: #ffffff;
			padding: 25rpx 0;
			margin: 60rpx 0;
			border-radius: 8rpx;
			background-color: #00A0DC;
		}

		.next_step_btn_def {
			display: flex;
			align-items: center;
			justify-content: center;
			color: #ffffff;
			padding: 25rpx 0;
			margin: 40rpx 0;
			border-radius: 8rpx;
			background-color: #E9E9E9;
		}

	}
</style>